package com.geeksx.trainer.controller;

import com.geeksx.trainer.service.QuestionTypeService;
import org.springframework.web.bind.annotation.*;
import com.geeksx.trainer.common.api.Result;
import com.geeksx.trainer.entity.QuestionType;

import java.util.List;

/**
 * 题目类型相关接口
 */
@RestController
@RequestMapping("/api/question-types")
public class QuestionTypeController {

    private final QuestionTypeService questionTypeService;

    public QuestionTypeController(QuestionTypeService questionTypeService) {
        this.questionTypeService = questionTypeService;
    }

    /** 获取所有题目类型 */
    @GetMapping("/list")
    public Result<List<QuestionType>> list() {
        return Result.success(questionTypeService.lambdaQuery()
                .orderByAsc(QuestionType::getSort)
                .list());
    }
}
